package com.rbh.visanyee.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Cacheable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

@Entity
@Table(name = "rbh_risk_acl")
@Cacheable
@Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
public class ACL implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ACL_ID", unique = true, nullable = false, columnDefinition = "smallint UNSIGNED")
    private Short aclId;
    @Column(name = "ACL_NAME", unique = true, nullable = false, length = 100)
    private String aclName;
    @Column(name = "ACL_AMOUNT", columnDefinition = "tinyint(2) UNSIGNED")
    private Byte aclAmount;
    @Basic(optional = false)
    @Column(name = "ACL_STATUS", columnDefinition = "boolean default true", nullable = false)
    private boolean aclStatus;
    @Column(name = "ACL_DESCRIPTION", length = 1024)
    private String aclDescription;
    @Basic(optional = false)
    @Column(name = "ACL_ORDER_NUMBER", columnDefinition = "tinyint UNSIGNED default 0", nullable = false)
    private short aclOrderNumber;
    @OneToMany(mappedBy = "acl", fetch = FetchType.LAZY)
    @Cascade({CascadeType.DETACH})
    private List<Privilege> privilegeList;

    public ACL() {
    }

    public ACL(Short aclId) {
        this.aclId = aclId;
    }

    public ACL(Short aclId, String aclName) {
        this.aclId = aclId;
        this.aclName = aclName;
    }

    public Short getAclId() {
        return aclId;
    }

    public void setAclId(Short aclId) {
        this.aclId = aclId;
    }

    public String getAclName() {
        return aclName;
    }

    public void setAclName(String aclName) {
        this.aclName = aclName;
    }

    public Byte getAclAmount() {
        return aclAmount;
    }

    public void setAclAmount(Byte aclAmount) {
        this.aclAmount = aclAmount;
    }

    public String getAclDescription() {
        return aclDescription;
    }

    public void setAclDescription(String aclDescription) {
        this.aclDescription = aclDescription;
    }

    public List<Privilege> getPrivilegeList() {
        return privilegeList;
    }

    public void setPrivilegeList(List<Privilege> privilegeList) {
        this.privilegeList = privilegeList;
    }

    public boolean isAclStatus() {
        return aclStatus;
    }

    public void setAclStatus(boolean aclStatus) {
        this.aclStatus = aclStatus;
    }

    public short getAclOrderNumber() {
        return aclOrderNumber;
    }

    public void setAclOrderNumber(short aclOrderNumber) {
        this.aclOrderNumber = aclOrderNumber;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (aclId != null ? aclId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ACL)) {
            return false;
        }
        ACL other = (ACL) object;
        if ((this.aclId == null && other.aclId != null) || (this.aclId != null && !this.aclId.equals(other.aclId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.rbh.risk.entity.ACL[ aclId=" + aclId + " ]";
    }
}
